/*
 * @Author: YuanSong 
 * @Date: 2021-11-24 21:28:58 
 * @Last Modified by: YuanSong
 * @Last Modified time: 2021-12-02 21:54:59
 */

import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import NavbarLeft from "@components/Navbar/NavbarLeft";
import NavbarMiddle from "@components/Navbar/NavbarMiddle";
import NavbarRight from "@components/Navbar/NavbarRight";
import ThemeSelector from "@components/Navbar/ThemeSelector";
import { IGlobalReduceState } from '@/redux/reducers/global';
import { requestLogOut } from '@redux/actions/user';
import {connect} from 'react-redux';
import { bindActionCreators } from 'redux';
import { AppState } from '@/redux/reducers';
import {requestModifyUserInfo} from "@redux/actions/user";

type IProps = IGlobalReduceState & RouteComponentProps &{
    requestLogOut:typeof requestLogOut,
    requestModifyUserInfo:typeof requestModifyUserInfo,
};
class Navbar extends React.Component<IProps>{
    constructor(props: any){
        super(props);
    }

    readonly state = {
        /** 搜索字符 */
        searchStr: ''
    }
    public componentDidMount() {
        console.log('Navbar componentDidMount');
    }

    render(){
        return (
            <div className="Navbar-Wrapper">
                <NavbarLeft />
                <NavbarMiddle />
                <NavbarRight />
                <ThemeSelector requestModifyUserInfo={this.props.requestModifyUserInfo} ></ThemeSelector>
            </div>
        )
    }

}

export default connect(
    (state:AppState)=>state.global,
    (dispatch)=>
        bindActionCreators({
            requestLogOut,
            requestModifyUserInfo
        },
        dispatch
    )
)(withRouter(Navbar));